<?php
include_once 'connection/connection_database.php';
include_once 'app/model/category/process.php';
include_once 'app/model/board/process.php';
include_once 'app/model/page/process.php';
include_once 'app/model/upload/process.php';
include_once 'app/function/xulychuoi.php';

$categories = new Categories();
$board = new Boards();
$pages = new Pages();
$upload = new Upload();

$result = $categories->FillLimit();
$fillOneUpload = mysql_fetch_array($upload->FillAll());
$urlHome = explode("/", $url["home"]);
?>
<div id="images_link">
    <a href="dat-cau-hoi.html"><img src="images/anh-dat-cau-hoi.png" alt="Đặt câu hỏi cho Bravo" /></a>
    <a href="dia-chi.html"><img src="images/anh-dia-chi-cac-van-phong-tren-toan-quoc.png" alt="Địa chỉ văn phòng Bravolaw trên toàn quốc" /></a>
    <a href="download/export.php?file=<?php echo $fillOneUpload["upload_name"] ?>"><img src="images/anh-download-mau-to-khai.png" alt="Download mẫu tờ khai" /></a>
    <a href="lien-he.html"><img src="images/anh-lien-he-voi-chung-toi.png" alt="Liên hệ với công ty Bravolaw" /></a>
</div><!--End #images_link  -->
<?php
while ($rows = mysql_fetch_array($result)) {
    $resultBoard = $board->FillAllLimit($rows["category_id"]);
    $resultBoards = $board->FillAllLimit($rows["category_id"]);
    $i++;
    ?>
    <div id="tabbed_nav_<?= $i ?>" class="tabbed_nav">
        <div class="box-tabs">
            <h2 class="category"><?= $rows["category_name"] ?></h2>
        </div><!--End .box-tabs-->
        <div class="tabbed_area">
            <ul class="tabs">
                <?php
                while ($rowBoard = mysql_fetch_array($resultBoard)) {
                    $j++;
                    //var_export($rowBoard);  
                    ?>
                    <li><a href="" title='items_nav<?= $j ?>' class="<?php if($j==1) { ?>active <?php } ?>tab">
                            <span class="box-left"></span>
                            <span class="box-center"><?= $rowBoard["board_name"] ?></span>
                            <span class="box-right"></span></a>
                    </li>
                <?php } $j=0; ?>
                
            </ul><!--End .tabs-->
            <?php
            while ($rowBoards = mysql_fetch_array($resultBoards)) {
                $a++;
                $pageOne = $pages->FillOne($rowBoards["board_id"]);
                if($pageOne != ""){
                    ?>
                    <div id="items_nav<?php echo $a ?>" class="content_tab">
                        <div class="title_article">
                            <h2><img src="images/article-1.png" alt="" align="middle" /><a href="<?php echo $pageOne["page_link"].".html" ?>"><?php echo $pageOne["page_title"] ?></a><span class="counter_view">Có <?php echo $pageOne["page_counter"] ?> lượt xem</span></h2>
                            <h4><img src="images/calendar.png" alt="Ngày viết" /> Date :<?php echo $pageOne["page_date"] ?></h4>
                        </div><!--End .title_article-->
                        <div class="content_article">
                            <div>
                                <a href="<?php echo $pageOne["page_link"].".html" ?>"><img src="<?php echo $pageOne["page_image"] ?>" width="153" height="90" alt="" align="left" /></a>
                                <p class="some_text">
                                    <?php
                                    echo mb_substr($pageOne["page_summary"], 0, 300) . " [...]";
									//echo $pageOne["page_summary"];
                                    ?>
                                </p><!--End .some_text-->
                                <p class="more_details">
                                    <a href="<?php echo $pageOne["page_link"].".html" ?>">Xem thêm...</a>
                                </p><!--End .more_details-->
                                <div class="comments like share">
                                    <div id="fb-root"></div>
                                    <script>(function(d, s, id) {
                                        var js, fjs = d.getElementsByTagName(s)[0];
                                        if (d.getElementById(id)) return;
                                        js = d.createElement(s); js.id = id;
                                        js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1";
                                        fjs.parentNode.insertBefore(js, fjs);
                                    }(document, 'script', 'facebook-jssdk'));</script>
                                    <div class="fb-like" data-href="<?php echo $urlHome[1]."/".$pageOne["page_link"].".html" ?>" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true"></div>
                                </div><!--End .comments-->
                            </div><!--End-->
                        </div><!--End #content_article--> 
                        <div class="tags_article">
                            <img src="images/tags-1.png" alt="tags liên quan" />
                            <?php
                                $tags = explode(",", $pageOne["page_tag"]);
                                foreach ($tags as $_tags) {
									$_tags = trim(khongdau($_tags));
									$link_tags = strtolower(preg_replace('/[^a-z0-9]+/i','-',$_tags));	
                            ?>
                                    <a href="<?php echo $url["home"] ?>/tag/<?php echo $link_tags; ?>"><?php echo $_tags; ?></a> |
                            <?php } ?>
                        </div><!--End .tags_article-->
                        <div class="article_related">
                            <?php
                            $fillByBoard = $pages->FillOneByBoard($rowBoards["board_id"], $pageOne["page_id"]);
                            while ($_fillByBoard = mysql_fetch_array($fillByBoard)) {
                                ?>
                                <div class="col1">
                                    <h3><a href="<?php echo $_fillByBoard["page_link"].".html" ?>"><img src="images/bullet_article_related.png" alt="" /><?php echo $_fillByBoard["page_title"] ?></a></h3>
                                </div><!--End .col1-->
                            <?php } ?>
                            <div class="clear"></div>
                        </div><!--End .article_related-->
                    </div><!--End .content_tab-->
            <?php
                }
            } $a=0;
            ?>
        </div><!--End .tabble_area-->
        <div class="box_tabs_nav_bottom"></div><!--End .box_tabs_bottom-->
    </div><!--End #tabble_nav_1-->
<?php } ?>
</div><!--End tabbed_nav-->